<div ng-controller="roleInfoController">
    <!-- begin breadcrumb -->
    <ol class="breadcrumb pull-right">
        <li><a ui-sref="app.home"></a>汇票线</li>
        <li><a ui-sref="app.setting">系统设置</a></li>
        <li class="active">角色管理</li>
    </ol>
    <!-- end breadcrumb -->
    <!-- begin page-header -->
    <h1 class="page-header"><i class="fa fa-lg text-success fa-cog"></i> 角色管理</h1>
    <!-- end page-header -->
    
    <!-- begin row -->
    <div class="row">
        <!-- begin col-12 -->
        <div class="col-md-12">
            <!-- begin panel -->
            <div class="panel panel-inverse">
                <div class="panel-heading">
                    <div class="panel-heading-btn">
                        <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-default" data-click="panel-expand"><i class="fa fa-expand"></i></a>
                        <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-success" data-click="panel-reload"><i class="fa fa-repeat"></i></a>
                        <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-warning" data-click="panel-collapse"><i class="fa fa-minus"></i></a>
                        <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-danger" data-click="panel-remove"><i class="fa fa-times"></i></a>
                    </div>
                    <h4 class="panel-title">角色管理</h4>
                </div>
                <div class="panel-body">
                    <div class="form-inline filter-option">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="pull-right">
                                    <input type="text" ng-model="filter.keyword" class="form-control input-sm" placeholder="关键词" />
                                    <button class="btn btn-sm btn-info" ng-click="reflash()"><i class="fa fa-search"></i> 筛选</button>
                                    <button class="btn btn-sm btn-success" ng-click="edit()"><i class="fa fa-plus-circle"></i> 新增</button>
                                    <button class="btn btn-sm btn-success" ng-click="copy()"><i class="fa fa-plus-circle"></i> 拷贝</button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <table id="data-table" ng-table="tableParams" template-pagination="template/pagination.html" class="table table-striped table-bordered table-hover table-condensed">
                        <tr ng-repeat="item in $data">
                            <td data-title="'序号'" width="10%" class="text-center">{{ first + $index }}</td>
                            <td data-title="'角色'" class="text-center">{{ item.role_name }}</td>
                            <td data-title="'描述'" class="text-center">{{ item.description }}</td>
                            <td class="text-center width-100 text-nowrap">
                                <button class="btn btn-success btn-xs" ng-click="power(item)"><i class="fa fa-edit"></i> 权限</button>
                                <button class="btn btn-success btn-xs" ng-click="edit(item)"><i class="fa fa-edit"></i> 编辑</button>
                                <button class="btn btn-success btn-xs" ng-click="remove(item)"><i class="fa fa-trash-o"></i> 删除</button>
                            </td>
                        </tr>
                    </table>
                </div>
                <!-- #modal-dialog -->
                <div class="modal fade" id="modal-edit">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <ng-form name="editForm" novalidate>
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                                    <h4 class="modal-title"><i class="fa fa-lg fa-edit text-success"></i> 角色信息</h4>
                                </div>
                                <div class="modal-body">
                                    <div class="form-horizontal form-inline">
                                        <div class="form-group width-full" ng-class="{ 'has-error': editForm.role_name.$invalid && !editForm.role_name.$pristine }">
                                            <label class="col-md-2 control-label"><font color="red">*</font> 角色名称：</label>
                                            <div class="col-md-10">
                                                <input type="text" name="role_name" ng-model="model.role_name" class="form-control width-full" required />
                                            </div>
                                        </div>
                                        <!--<div class="form-group" ng-class="{ 'has-error': editForm.id.$invalid && editForm.id.$dirty }">
                                            <label class="col-md-4 control-label"><font color="red">*</font> 用户：</label>
                                            <div class="col-md-8">
                                                <select name="id" ng-model="model.id" ng-options="item.id as item.username for item in users" class="form-control" required></select>
                                            </div>
                                        </div>-->
                                        <div class="form-group width-full" ng-class="{ 'has-error': editForm.description.$invalid && !editForm.description.$pristine }">
                                            <label class="col-md-2 control-label"><font color="red">*</font> 描述：</label>
                                            <div class="col-md-10">
                                                <input type="text" name="description" ng-model="model.description" class="form-control width-full" required />
                                            </div>
                                        </div>
                                        <!--<div class="form-group width-full">
                                            <label class="col-md-2 control-label">权限：</label>
                                            <div class="col-md-10">
                                                <ul>
                                                    <li ng-repeat="item in menus">
                                                        <input type="checkbox" ng-model="item.Checked" /> item.Name }}
                                                        <ul ng-if="item.Checked">
                                                            <li ng-repeat="item in item.SubMenus">
                                                                <input type="checkbox" ng-model="item.Checked" />
                                                                 item.Name }}
                                                                <ul ng-if="item.Checked">
                                                                    <li ng-repeat="item in item.SubMenus">
                                                                        <input type="checkbox" ng-model="item.Checked" />
                                                                         item.Name }}
                                                                    </li>
                                                                </ul>
                                                            </li>
                                                        </ul>
                                                    </li>
                                                </ul>
                                            </div>
                                        </div>-->
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <button type="submit" class="btn btn-sm btn-success" ng-click="save()" ng-disabled="editForm.$invalid"><i class="fa fa-save"></i> 保存</button>
                                    <button type="button" class="btn btn-sm btn-white" data-dismiss="modal"><i class="fa fa-share-square-o"></i> 关闭</button>
                                </div>
                            </ng-form>
                        </div>
                    </div>
                </div>
                <div class="modal fade" id="modal-copy">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <ng-form name="copyForm" novalidate>
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                                    <h4 class="modal-title"><i class="fa fa-lg fa-edit text-success"></i> 复制角色</h4>
                                </div>
                                <div class="modal-body">
                                    <div class="form-horizontal form-inline">
                                        <div class="form-group width-full">
                                            <label class="col-md-2 control-label"><font color="red">*</font> 拷贝角色名：</label>
                                            <div class="col-md-10">
                                                <select ng-model="model.id" ng-options="item.id as item.role_name for item in roleData" class="form-control input-sm">
                                                    <option value="">角色类型...</option>
                                                </select>
                                            </div>
                                        </div>
                                        
                                        <div class="form-group width-full" ng-class="{ 'has-error': editForm.role_name.$invalid && !editForm.role_name.$pristine }">
                                            <label class="col-md-2 control-label"><font color="red">*</font> 新角色名称：</label>
                                            <div class="col-md-10">
                                                <input type="text" name="role_name" ng-model="model.role_name" class="form-control width-full" required />
                                            </div>
                                        </div>
                                        <div class="form-group width-full" ng-class="{ 'has-error': editForm.description.$invalid && !editForm.description.$pristine }">
                                            <label class="col-md-2 control-label"><font color="red">*</font> 新角色描述：</label>
                                            <div class="col-md-10">
                                                <input type="text" name="description" ng-model="model.description" class="form-control width-full" required />
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <button type="submit" class="btn btn-sm btn-success" ng-click="submit()" ng-disabled="copyForm.$invalid"><i class="fa fa-save"></i> 保存</button>
                                    <button type="button" class="btn btn-sm btn-white" data-dismiss="modal"><i class="fa fa-share-square-o"></i> 关闭</button>
                                </div>
                            </ng-form>
                        </div>
                    </div>
                </div>
                <!-- #modal-dialog -->
                <div class="modal fade" id="modal-Resources">
                    <div class="modal-dialog" style="height:auto;width:1200px">
                        <div class="modal-content">
                            <ng-form name="ResourcesForm" novalidate>
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                                    <h4 class="modal-title"><i class="fa fa-lg fa-edit text-success"></i> 角色权限管理</h4>
                                </div>
                                <div class="modal-body">
                                    <div class="form-horizontal form-inline">
                                        <div class="controls row">
                                            <span ng-repeat="item in RoleResourceData">
                                                <span class="form-group width-full">
                                                    <label class="control-label-bill col-md-4 col-md-offset-1">{{ item.resource_name }}</label>
                                                    <span class="control-label-bill col-md-1">
                                                        <input type="checkbox" id="canpost" ng-model="item.can_post_checked" value="{{item.can_post}}"> 新增
                                                    </span>
                                                    <span class="control-label-bill col-md-1">
                                                        <input type="checkbox" id="candelete" ng-model="item.can_delete_checked" value="{{item.can_delete}}"> 删除
                                                    </span>
                                                    <span class="control-label-bill col-md-1">
                                                        <input type="checkbox" id="canput" ng-model="item.can_put_checked" value="{{item.can_put}}"> 修改
                                                    </span>
                                                    <span class="control-label-bill col-md-1">
                                                        <input type="checkbox" id="canget" ng-model="item.can_get_checked" value="{{item.can_get}}"> 查询
                                                    </span>
                                                    <span class="col-md-2 col-md-offset-1">
                                                        <button type="submit" class="btn btn-xs btn-success" ng-click="Determine(item)" ng-disabled="ResourcesForm.$invalid"><i class="fa fa-save"></i> 保存</button>
                                                        <button class="btn btn-success btn-xs" ng-click="removePower(item)"><i class="fa fa-trash-o"></i> 删除</button>
                                                    </span>
                                                </span>
                                            </span>
                                            <span class="form-group width-full">
                                                <div class="control-label-bill col-md-4 col-md-offset-1">
                                                    <div>
                                                        <select ng-model="model.resource_id" ng-options="item.id as item.resource_name for item in allResources" class="form-control input-sm">
                                                            <option value="">--选择资源类型--</option>
                                                        </select>
                                                    </div>
                                                </div>
                                                <span class="control-label-bill col-md-1">
                                                    <input type="checkbox" ng-model="model.can_post" ng-true-value="1"> 新增
                                                </span>
                                                <span class="control-label-bill col-md-1">
                                                    <input type="checkbox" ng-model="model.can_delete" ng-true-value="1"> 删除
                                                </span>
                                                <span class="control-label-bill col-md-1">
                                                    <input type="checkbox" ng-model="model.can_put" ng-true-value="1"> 修改
                                                </span>
                                                <span class="control-label-bill col-md-1">
                                                    <input type="checkbox" ng-model="model.can_get" ng-true-value="1"> 查询
                                                </span>
                                                <span class="col-md-2 col-md-offset-1">
                                                    <button type="submit" class="btn btn-xs btn-success" ng-click="addPower(model)" ng-disabled="ResourcesForm.$invalid"><i class="fa fa-save"></i> 增加</button>
                                                </span>
                                            </span>
                                        </div>
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <!--<button type="submit" class="btn btn-sm btn-success" ng-click="Determine()" ng-disabled="ResourcesForm.$invalid"><i class="fa fa-save"></i> 保存</button>-->
                                    <button type="button" class="btn btn-sm btn-white" data-dismiss="modal"><i class="fa fa-share-square-o"></i> 关闭</button>
                                </div>
                            </ng-form>
                        </div>
                    </div>
                </div>

                <div class="modal fade" id="modal-users">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                                <h4 class="modal-title"><i class="fa fa-lg fa-edit text-success"></i>{{  model.Name }}</h4>
                            </div>
                            <div class="modal-body">
                                <div class="table-responsive">
                                    <table class="table table-striped">
                                        <thead>
                                            <tr>
                                                <th>序号</th>
                                                <th>用户</th>
                                                <th>账号</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr ng-repeat="item in users">
                                                <td>{{ $index + 1 }}</td>
                                                <td>{{ item.usename }}</td>
                                                <td>{{ item.Account }}</td>
                                                <td><button class="btn btn-success btn-xs" ng-click="removeUser(item)"><i class="fa fa-trash-o"></i> 删除</button></td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button class="btn btn-sm btn-success" ng-click="selectUser(model.OrgID)"><i class="fa fa-plus-circle"></i> 添加</button>
                                <button class="btn btn-sm btn-white" data-dismiss="modal"><i class="fa fa-share-square-o"></i> 关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- #modal-dialog -->
                <!--<div class="modal fade" id="modal-selectUser" ng-include="'template/selectUser.html'"></div>-->
            </div>
            <!-- end panel -->
        </div>
        <!-- end col-12 -->
    </div>
    <!-- end row -->
</div>